
package {{package}};

import java.util.List;
import java.util.Map;
import java.util.Optional;

import jakarta.annotation.Priority;

import io.helidon.dbclient.DbColumn;
import io.helidon.dbclient.DbMapper;
import io.helidon.dbclient.DbRow;
import io.helidon.dbclient.spi.DbMapperProvider;

/**
 * Provider for PokemonType mappers.
 *
 * Pokemon, and Pokemon character names are trademarks of Nintendo.
 */
@Priority(1000)
public class PokemonTypeMapperProvider implements DbMapperProvider {
    private static final PokemonTypeMapper MAPPER = new PokemonTypeMapper();

    @SuppressWarnings("unchecked")
    @Override
    public <T> Optional<DbMapper<T>> mapper(Class<T> type) {
        return type.equals(PokemonType.class) ? Optional.of((DbMapper<T>) MAPPER) : Optional.empty();
    }

    /**
     * Maps database types to a PokemonType class.
     */
    static class PokemonTypeMapper implements DbMapper<PokemonType> {

        @Override
        public PokemonType read(DbRow row) {
            DbColumn id = row.column("{{id}}");
            DbColumn name = row.column("{{name}}");
            return new PokemonType({{PokemonType-constructor-arg}});
        }

        @Override
        public Map<String, ?> toNamedParameters(PokemonType value) {
            throw new UnsupportedOperationException("Not supported");
        }

        @Override
        public List<?> toIndexedParameters(PokemonType value) {
            throw new UnsupportedOperationException("Not supported");
        }
    }
}
